Skip to content

Conversation

@eladb3
Copy link
Contributor

@eladb3 eladb3 commented Feb 11, 2026

Description

Claude Opus 4.6 via Bedrock returns a different error message when the context window is exceeded:

botocore.errorfactory.ValidationException: An error occurred (ValidationException)
when calling the ConverseStream operation: The model returned the following errors:
prompt is too long: 903884 tokens > 200000 maximum

This message was not recognized by the Bedrock provider's BEDROCK_CONTEXT_WINDOW_OVERFLOW_MESSAGES list, causing the agent to raise a raw ClientError instead of ContextWindowOverflowException. This prevents the agent's reduce_context() recovery mechanism from triggering.

The Anthropic direct API provider already handles this message ("prompt is too long:" in AnthropicModel.OVERFLOW_MESSAGES), but the Bedrock provider was missing it.

Fix: Add "prompt is too long" to BEDROCK_CONTEXT_WINDOW_OVERFLOW_MESSAGES.

Related Issues

N/A

Documentation PR

N/A

Type of Change

Bug fix

Testing

Added a parametrized test (test_stream_context_window_overflow) covering all 4 overflow message variants, including the new "prompt is too long" message.

  • I ran hatch run prepare

Results: 1764 passed, 4 skipped, 0 failures.

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…sages

Claude Opus 4.6 via Bedrock returns a different error message when the
context window is exceeded:

  "prompt is too long: 903884 tokens > 200000 maximum"

This message was not recognized by the Bedrock provider, causing the
agent to raise a raw ClientError instead of ContextWindowOverflowException.
The Anthropic direct API provider already handles this message.

Add "prompt is too long" to BEDROCK_CONTEXT_WINDOW_OVERFLOW_MESSAGES
and add parametrized tests covering all overflow message variants.
@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Unshure Unshure merged commit 66fb308 into strands-agents:main Feb 11, 2026
13 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants